package HttpStudy.JavaNetClass;

/***Created by moyongzhuo
 *On 2017/9/22  ***11:39.
 ******/
import java.net.*;

public class DomainName
{
    public static void outHostName(InetAddress address, String s)
    {
        System.out.println("通过" + s + "创建InetAddress对象");
        System.out.println("主 机 名:" + address.getCanonicalHostName());
        System.out.println("主机别名:" + address.getHostName());
        System.out.println("");
    }
    public static void main(String[] args) throws Exception
    {
        outHostName(InetAddress.getLocalHost(), "getLocalHost方法");
        outHostName(InetAddress.getByName("www.ibm.com"), "www.ibm.com");
        outHostName(InetAddress.getByName("www.126.com"), "www.126.com");
        outHostName(InetAddress.getByName("202.108.9.77"), "202.108.9.77");
        outHostName(InetAddress.getByName("211.100.26.121"), "211.100.26.121");
    }
}
